import { defineStore } from 'pinia'
import { getLogLoginPage, getLogOperatePage } from '@/api/log'

export const logStore = defineStore('log', {
  state: () => ({
    loginLogs: [],
    operateLogs: [],
    pagination: {
      page: 1,
      limit: 10,
      total: 0
    }
  }),
  actions: {
    async fetchLoginLogs(params) {
      const res = await getLogLoginPage({
        ...this.pagination,
        ...params
      })
    //   console.log(res)
      this.loginLogs = res.list
      this.pagination.total = res.total
    },
    async fetchOperateLogs(params) {
      const res = await getLogOperatePage({
        ...this.pagination,
        ...params
      })
      this.operateLogs = res.list
      this.pagination.total = res.total
    }
  }
})